home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / atutr202.zip / meridian.ada < prev    next >
Text File  |  1992-09-04  |  3KB  |  67 lines

  1. -- MERIDIAN.ADA   Ver. 2.02   4-SEP-1992   Copyright 1988-1992 John J. Herro
  2. -- Software Innovations Technology
  3. -- 1083 Mandarin Drive NE, Palm Bay, FL  32905-4706   (407)951-0233
  4. --
  5. -- Compile this before compiling ADA_TUTR.ADA, when using a PC with a Meridian
  6. -- Ada compiler and the Meridian DOS Environment Library.
  7. --
  8. with TTY;
  9. package CUSTOM_IO is
  10.    type COLOR is (BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE);
  11.    FOREGRND_COLOR   : COLOR := WHITE;                 -- Default values in case
  12.    BACKGRND_COLOR   : COLOR := BLACK;                 -- ADA-TUTR finds no User
  13.    BORDER_COLOR     : COLOR := BLACK;                 -- File.
  14.    FORE_COLOR_DIGIT : CHARACTER := CHARACTER'VAL(COLOR'POS(FOREGRND_COLOR)+48);
  15.    BACK_COLOR_DIGIT : CHARACTER := CHARACTER'VAL(COLOR'POS(BACKGRND_COLOR)+48);
  16.    NORMAL_COLORS    : STRING(1 .. 10) := ASCII.ESC & "[0;3" &
  17.                             FORE_COLOR_DIGIT & ";4" & BACK_COLOR_DIGIT & "m";
  18.    CLEAR_SCRN       : constant STRING := ASCII.ESC & "[H" & ASCII.ESC &"[2J";
  19.  
  20.    procedure SET_BORDER_COLOR (TO   : in COLOR);
  21.    procedure GET              (CHAR : out CHARACTER);
  22.    procedure PUT              (CHAR : in  CHARACTER) renames TTY.PUT;
  23.    procedure PUT              (STR  : in  STRING)    renames TTY.PUT;
  24.    procedure PUT_LINE         (STR  : in  STRING)    renames TTY.PUT_LINE;
  25.    procedure GET_LINE         (STR  : out STRING; LAST : out NATURAL);
  26.    procedure NEW_LINE;
  27. end CUSTOM_IO;
  28.  
  29. with INTERRUPT;
  30. package body CUSTOM_IO is
  31.    procedure SET_BORDER_COLOR(TO : in COLOR) is
  32.       --
  33.       -- This procedure sets the border color on a PC by calling interrupt
  34.       -- 10 hex.  Before the call, register AH is set to service number 0B hex,
  35.       -- BH is set to zero, and BL is set to an integer as shown in the
  36.       -- declaration of COLOR_NUMBER below.  Note that the integers in
  37.       -- COLOR_NUMBER are bit reversed from the integers defining foreground
  38.       -- and background colors in ANSI escape sequences.  Note also that some
  39.       -- color PCs don't have separate border colors.
  40.       --
  41.       REGIS_BLOCK  : INTERRUPT.REGISTERS;
  42.       COLOR_NUMBER : constant array(COLOR) of INTEGER :=
  43.           (BLACK   => 0,   RED     => 4,   GREEN   => 2,   YELLOW  => 6,
  44.            BLUE    => 1,   MAGENTA => 5,   CYAN    => 3,   WHITE   => 7);
  45.    begin
  46.       REGIS_BLOCK.AX := 16#0B00#;
  47.       REGIS_BLOCK.BX := 16#0000# + COLOR_NUMBER(TO);
  48.       INTERRUPT.VECTOR(ON => 16#10#, REGISTER_BLOCK => REGIS_BLOCK);
  49.    end SET_BORDER_COLOR;
  50.  
  51.    procedure GET(CHAR : out CHARACTER) is
  52.    begin
  53.       CHAR := TTY.GET(NO_ECHO => TRUE);
  54.    end GET;
  55.  
  56.    procedure GET_LINE(STR : out STRING; LAST : out NATURAL) is
  57.    begin
  58.       TTY.GET(STR, LAST);
  59.       NEW_LINE;
  60.    end GET_LINE;
  61.  
  62.    procedure NEW_LINE is
  63.    begin
  64.       PUT_LINE("");
  65.    end NEW_LINE;
  66. end CUSTOM_IO;
  67.